<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='global-property-'>/**
</span> * @ignore
 * traversal ie hack
 * @author yiminghe@gmail.com
 */
KISSY.add('dom/ie/traversal', function (S, Dom) {
    Dom._contains = function (a, b) {
        if (a.nodeType == Dom.NodeType.DOCUMENT_NODE) {
            a = a.documentElement;
        }
        // !a.contains =&gt; a===document || text
        // 注意原生 contains 判断时 a===b 也返回 true
        b = b.parentNode;

        if (a == b) {
            return true;
        }

        // when b is document, a.contains(b) 不支持的接口 in ie
        if (b &amp;&amp; b.nodeType == Dom.NodeType.ELEMENT_NODE) {
            return a.contains &amp;&amp; a.contains(b);
        } else {
            return false;
        }
    };

    var div = document.createElement(&quot;div&quot;);
    div.appendChild(document.createComment(&quot;&quot;));

    var getElementsByTagName;

    if (div.getElementsByTagName(&quot;*&quot;).length) {
        getElementsByTagName = function (name, context) {
            var nodes = context.getElementsByTagName(name),
                needsFilter = name == '*';
            // &lt;input id='length'&gt;
            if (needsFilter || typeof nodes.length != 'number') {
                var ret = [],
                    i = 0,
                    el;
                while (el = nodes[i++]) {
                    if (!needsFilter || el.nodeType === 1) {
                        ret.push(el);
                    }
                }
                return ret;
            } else {
                return nodes;
            }
        };
    } else {
        getElementsByTagName = function (name, context) {
            return context.getElementsByTagName(name);
        };
    }

    Dom._getElementsByTagName = getElementsByTagName;

    var getAttr = Dom._getSimpleAttr;
    Dom._getElementById = function (id, doc) {
        var el = doc.getElementById(id);
        if (el &amp;&amp; getAttr(el, 'id') !== id) {
            var children = getElementsByTagName('*', doc);
            for (var i = 0, l = children.length; i &lt; l; i++) {
                if (getAttr(children[i], 'id') == id) {
                    return children[i];
                }
            }
        }
        return el;
    };
}, {
    requires: ['dom/base']
});</pre>
</body>
</html>
